<script>
    //使用IIFE+闭包+class+Symbol实现私有成员
    var Shape=function(){
        let widthname=Symbol("width");
        class Shape{
            constructor(w){
                this[widthname]=w;  //使用Symbol作为属性名,定义宽度
            }
            get width(){
                return this[widthname];
            }
            set width(value){
                if(value>0){
                    this[widthname]=value;
                }else{
                    throw "宽度必须大于0";
                }
            }
        }
        return Shape;
    }();
    let s1=new Shape();
    s1.width=100;
    console.log(s1.width);
    s1.width=-100;
</script>